<template>
  <div>
    <h1>我是day06组件</h1>
  </div>
</template>

<script>
import pubsub from "pubsub-js"
export default {
    name:"MyDay06",
    data() {
        return {

        }
    },
    methods:{
        func2(a,b){
            console.log(222222222);
            console.log(a);
            console.log(b);
        }
    },
    mounted(){
        this.$bus.$on("wq",(a)=>{
            console.log(11111111111);
            console.log(a);
            console.log(this.$bus);
            console.log(this.$bus.age);
        })
        // 消息订阅
        this.pubId = pubsub.subscribe("demo",this.func2)
    },
    beforeDestroy(){
        // 取消全局事件
        this.$bus.$off("wq");
        // 取消订阅
        pubsub.unsubscribe(this.pubId);
    }
}
</script>

<style>

</style>